import { request } from "@/utils/service"

export interface IInvitationCode {
  id?: number
  invitationCode: string
  inviterId?: number
  inviterAccount?: string
}

export interface ICreateInvitationCodeDataApi {
  invitationCode: string
  inviterId?: number
  inviterAccount?: string
}

export interface IBindInviterAccountDataApi {
  inviterId: number
  inviterAccount: string
}

export interface IGetInvitationCodeListDataApi {
  /** 当前页码 */
  pageNum: number
  /** 查询条数 */
  pageSize: number
}

export function createInvitationCode(data: ICreateInvitationCodeDataApi) {
  return request({
    url: "/travel/manage/invitationCode/create",
    method: "post",
    data
  })
}

export function bindInviterAccount(id: number, data: IBindInviterAccountDataApi) {
  return request({
    url: "/travel/manage/invitationCode/update/" + id,
    method: "put",
    data
  })
}

export function getInvitationCodeList(params: IGetInvitationCodeListDataApi) {
  return request({
    url: "/travel/manage/invitationCode/list",
    method: "get",
    params
  })
}
